//
//  BankButton.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/9/25.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class BankButton: UIButton {
    
    fileprivate let arrowImage = UIImageView()
    fileprivate let textLabel = UILabel()
    
    var title : String! {
        didSet{
            textLabel.text = title
        }
    }
    
    var image : UIImage! {
        
        didSet{
            arrowImage.image = image
        }
    }
    
    init(title:String) {
        super.init(frame: .zero)
        
        self.layer.borderWidth = 1
        self.layer.borderColor = UIColor.lineColor().cgColor
        
        textLabel.text = title
        textLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(textLabel)
        
        arrowImage.image = #imageLiteral(resourceName: "bottom_arrow")
        self.addSubview(arrowImage)
        
        textLabel.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.width.greaterThanOrEqualTo(10)
            make.height.greaterThanOrEqualTo(10)
            make.centerX.equalToSuperview().offset(RATIO_H(maxNum: -11))
        }
        
        arrowImage.snp.makeConstraints { (make) in
            make.left.equalTo(textLabel.snp.right).offset(RATIO_H(maxNum: 2))
            make.centerY.equalTo(textLabel)
            make.width.height.equalTo(RATIO_H(maxNum: 20))
        }
        
    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
